Step 1 - Interpolate the rotation of the compass dial

In this step of the tutorial you use a Property Target Interpolator to interpolate the rotation of the compass dial from the current direction to a target direction over time.

Assets for the tutorial

The starting point of this tutorial is the Interpolate.kzproj Kanzi Studio project file stored in the <KanziWorkspace>/Tutorials/Interpolate/Start directory.

The <KanziWorkspace>/Tutorials/Interpolate/Completed directory contains the completed Kanzi Studio project of this tutorial.

The starting point project contains the content you need to complete this tutorial:

Interpolate the rotation of the compass dial

In this section you animate the rotation of the compass dial so that when the direction of travel changes, the Property Target Interpolator interpolates the current value to the target value over time.

To interpolate the rotation of the compass dial:

  1. In the Library press Alt and right-click Property Types, select Property Type, and in the New Property Type window set:You create the Interpolate.Interpolator property type because you want to interpolate the Interpolate.Direction property whose data type is integer. To interpolate a property whose data type is not a float, you need to create a float property type and bind the property you want to interpolate to the float property you created.
  2. Bind to the property you created in the previous step the rotation of the Dial node:
    1. In the Project select the Dial node, in the Properties in the Bindings click the existing binding to edit it, and in the Binding Argument Editor set the Expression to:
      CreateRotationZ({@./Interpolate.Interpolator})
      Click Save.
      You use this binding to rotate the Dial node based on the value of the Interpolate.Interpolator property.
    2. In the Properties click + Add Binding and in the Binding Argument Editor set:
      • Property to Interpolate.Interpolator
      • Expression to
        {#RootPage/Interpolate.Direction}
      Click Save.
      You bind the Interpolate.Interpolator property to the Interpolate.Direction property in the RootPage node with which you control the rotation.
  3. Add a Property Target Interpolator to the node the rotation of which you want to interpolate:
    1. In the Project select the Dial node, in the Node Components > Animation section click + Add Animation and select Property Target Interpolator.
      You use the Property Target Interpolator to interpolate the value of the Interpolate.Interpolator property to a target value over time. The bindings you created in the previous step apply this change to the rotation of the Dial node.
    2. In the Node Components > Animation section in the Property Target Interpolator set:
      • Interpolated Property Type to Interpolate.Interpolator
      • Acceleration to 5
        You use Acceleration to adjust the acceleration coefficient of interpolation. The higher the value the faster the property reaches its final value.
      • Drag to 2
        You use Drag to adjust the drag coefficient of interpolation. The lower the value the faster the property reaches its final value.

Now when you change the value of the direction XML element in the <ProjectName>/Generic/Compass.xml and save the file, the Property Target Interpolator interpolates the rotation of the compass dial to the target value over time.

TIP

By default the Preview updates content only when the Kanzi Studio window is focused. To see the changes in your Kanzi Studio project when the Kanzi Studio window is not focused, in Kanzi Studio select Edit > User Preferences and in the Advanced tab enable the Update the Preview when Kanzi Studio is not focused.



< INTRODUCTION
NEXT STEP >

See also

Interpolating property values

Using bindings

Using triggers

Data sources

Creating state managers